<%@ page contentType="text/html; charset=UTF-8"%>
<%@ page import="com.sinodata.bsm.common.vo.FaultTrapMsg"%>
<%@ include file="../include/taglib.jsp"%>
<%
    response.setHeader("Cache-Control", "no-store");
	response.setHeader("Pragrma", "no-cache");
	response.setDateHeader("Expires", 0);
%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
<head>
<title>TRAP列表页面</title>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<meta http-equiv="pragmaR" content="no-cache" />
<meta http-equiv="cache-control" content="no-cache" />
<meta http-equiv="expires" content="0" />
<%@ include file="../include/common.jsp"%>
<%@ include file="../include/table.jsp"%>
 <%@ include file="../include/form.jsp"%>
<%@ include file="../include/jbox.jsp"%>

<link rel="stylesheet" type="text/css"
	href="${pageContext.request.contextPath}/style/default/bsm/sub_menu.css" />
	
  <link href="${pageContext.request.contextPath}/style/default/form/ui.tabs.css" type="text/css" rel="stylesheet" media="print, projection, screen"/>

<link rel="stylesheet" type="text/css"
	href="${pageContext.request.contextPath}/style/default/bsm/fault/trap.css" />
	
<script type="text/javascript" src="<%=request.getContextPath()%>/scripts/jsframework.js"></script>
<script src="${pageContext.request.contextPath}/js/crontab/Simple_util.js"></script>
<script src="${pageContext.request.contextPath}/js/TimeUnit/TimeUnit.js"></script>
<script src="${pageContext.request.contextPath}/js/TimeUnit/TimeUnit_data_zh_CN.js"></script>
	
<script type=text/javascript>
	function back(){
		  window.history.back();
	}
	
	function pageReset(){
		$("#trapform").get()[0].reset(); 
	}
	
	var timeout = 50;
	function timer(){
        $('#timeCount').css('font','#ff0000').text(timeout);
        
        if (timeout == 0) {
        	 window.history.back();
        }
        else {
            setTimeout("timer()", 1);
        }
        timeout--;
	}
	
	
	
	function add(){
		 $.ajax({
			   type: "POST", 
			   url: '${pageContext.request.contextPath}/fault/trap-rule!save.action', //请求的action
			   data: $("#trapform").serialize(), //传的参数
			   dataType: 'json',
			   success: function(data){ //结果
				    window.setTimeout(function () { $.jBox.tip('规则添加成功', 'success'); }, 100);
			   }
		});
	}
	
	
	$(function() {
		  $.formValidator.initConfig({formid:"trapform"
	          ,onerror:function(msg){}
	          ,onsuccess:function(){
	        	  		add();
	          			return false;
	          }
	      });
		  $("#eventType").formValidator({onshow:"不能为空",onfocus:"不能为空",oncorrect:"输入正确"})
			 .functionValidator({
					    fun:function(val,elem){
					    	    if(val == null){
					    	        return "不能为空";
					    	    }
					    	    return true;
						}
			});
		  
		  $("#name").formValidator({onshow:"请输入字符串 (1-128)",onfocus:"请输入字符串 (1-128)",oncorrect:"输入正确"}).inputValidator({min:1,onerror:"不能为空"})
		  .functionValidator({
			    fun:function(val,elem){
			    	    if(val.replace(/[^\x00-\xff]/g, "xx").length > 128){
			    	        return "长度超出最大范围";
			    	    }
			    	    return true;
				}
	  	  })
	});
</script>
</head>
<body >
		
	<div class="top" id="top" style="">
		<ul>
		    <li class="li-a" idValue="common">新增TRAP规则
			</li>
		</ul>
	</div>
	
	
	
	<div id="addDiv" class="rule-add">
				<form action="" id="trapform" name=""trapform"" method="post">
				<div id="views" style="position:absolute; visibility:hidden;border:2px solid #CCC;background-color:white;">
				</div>
				    <input type="hidden" id="resId" name="resId" style="width: 200px;" value=${resId} ">
					<table class="table_eidt">
			  			<tr style="height:40px">
				    		<td class="td_left" width="120px">
								<span class="span_alert">*</span>规则名称
				    		</td>
				    		<td class="td_right">
				    			<input type="text" id="name" name="name" style="width: 200px;">
				    			<span class="pageTip" id="nameTip"></span>
				    		</td>
			    		</tr>
			    	   <!-- 
			    		<tr style="height:40px">
				    		<td class="td_left" width="120px">
								资源ID
				    		</td>
				    		<td class="td_right">
				    			<input type="text" id="resId" name="resId" style="width: 200px;" value=${resId} ">
				    		</td>
				    		<span class="pageTip" style="width:200px"></span>
			    		</tr>
			    		 -->
			    		<tr style="height:40px">
				    		<td class="td_left" width="120px">
								<span class="span_alert">*</span>事件类别
				    		</td>
				    		<td class="td_right">
				    			<select name="eventType" id="eventType" style="width: 200px">
						          	<c:forEach items="${eventTypeList}" var="e">
						          		<option value=${e.id}>${e.name}</option>
									</c:forEach>
				             	</select>
				             	<span class="pageTip" id="eventTypeTip"></span>
				    		</td>
			    		</tr>
			    		<!-- 
			    		<tr style="height:40px"  id="durationTd">
			    			<td class="td_left">持续时间</td>
			    			<td class="td_right">
			    				<div id="duration"></div>
			    				<script type="text/javascript">
			    					stu = new SimpleTimeUnit("duration","ddHHmm");
			    					stu.show();
			    				</script>
			    			</td>
			    			<span class="pageTip" style="width:200px"></span>
		    			</tr>
		    			 -->
			    		<tr style="height:40px">
				    		<td class="td_left">
								<span class="span_alert">*</span>事件级别
				    		</td>
				    		<td class="td_right" style="line-height:16px;">
				    		  <input style="float:left;" type="radio" name="eventLevel" id="eventLevels1" alue="2">
				    		  <label class="event-level event-l2" for="eventLevels1">轻微</label>
					          <input style="float:left;" type="radio" name="eventLevel" id="eventLevels2" value="3" checked="checked">
					           <label class="event-level event-l3" for="eventLevels2">警告</label>
					          <input style="float:left;" type="radio" name="eventLevel" id="eventLevels3" value="4">
					          <label class="event-level event-l4" for="eventLevels3">重要</label>
					          <input style="float:left;" type="radio" name="eventLevel" id="eventLevels4" value="5">
					          <label class="event-level event-l5" for="eventLevels4">严重</label>
				    		</td>
				    		<span class="pageTip" style="width:200px"></span>
			    		</tr>
			    			<tr >
				    		<td class="filt-tip" colspan="2">
								提示：以下为过滤条件，为空表示全部过滤，符合过滤条件的TRAP会被转换为事件!!
				    		</td>
			    		</tr>
			    		<!--  
			    		<tr style="height:40px">
				    		<td class="td_left">
								源IP
				    		</td>
				    		<td class="td_right">
				    			<input type="text" id="filtIp" name="filtIp" style="width: 200px;">
				    		</td>
				    		<span class="pageTip" style="width:200px"></span>
			    		</tr>
			    		
			    		<tr style="height:40px">
				    		<td class="td_left">
								TRAP安全级别
				    		</td>
				    		<td class="td_right">
				    			<input type="text" id="filtLevel" name="filtLevel" maxlength="1" value="" style="width: 200px;">
				    		</td>
				    		<span class="pageTip" style="width:200px"></span>
			    		</tr>
			    		-->
			    		<tr style="height:40px">
				    		<td class="td_left">
								 差错状态
				    		</td>
				    		<td class="td_right" style="line-height:16px;">
				    		  <input style="float:left;" type="checkbox" name="filtStatus" id="errstatus0" value="0">
				    		  <label class="error-status"  for="errstatus0">NoError</label>
				    		  <input style="float:left;" type="checkbox" name="filtStatus" id="errstatus1" value="1">
				    		  <label class="error-status"  for="errstatus1">TooBig</label>
					          <input style="float:left;" type="checkbox" name="filtStatus" id="errstatus2" value="2">
					          <label class="error-status" for="errstatus2">NoSuchName</label>
					          <input style="float:left;" type="checkbox" name="filtStatus" id="errstatus3" value="3">
					          <label class="error-status" for="errstatus3">BadValue</label>
					          <input style="float:left;" type="checkbox" name="filtStatus" id="errstatus4" value="4">
					          <label class="error-status" for="errstatus4">ReadOnly</label>
					          <input style="float:left;" type="checkbox" name="filtStatus" id="errstatus5" value="5">
					          <label class="error-status" for="errstatus5">genErr</label>
				    		</td>
				    		<span class="pageTip" style="width:200px"></span>
			    		</tr>
			    		
			    		<tr style="height:40px">
				    		<td class="td_left">
								 TRAP类别
				    		</td>
				    		<td class="td_right" style="line-height:16px;">
				    		  <input style="float:left;" type="checkbox" name="filtGeneric" id="generictrap0" value="0">
				    		  <label class="error-status"  for="generictrap0">冷启动</label>
				    		  <input style="float:left;" type="checkbox" name="filtGeneric" id="generictrap1" value="1">
				    		  <label class="error-status"  for="generictrap1">热启动</label>
					          <input style="float:left;" type="checkbox" name="filtGeneric" id="generictrap2" value="2">
					          <label class="error-status" for="generictrap2">链路关闭</label>
					          <input style="float:left;" type="checkbox" name="filtGeneric" id="generictrap3" value="3">
					          <label class="error-status" for="generictrap3">链路恢复</label>
					          <input style="float:left;" type="checkbox" name="filtGeneric" id="generictrap4" value="4">
					          <label class="error-status" for="generictrap4">未授权访问</label>
					          <input style="float:left;" type="checkbox" name="filtGeneric" id="generictrap5" value="5">
					          <label class="error-status" for="generictrap5">边际网关丢失</label>
					          <input style="float:left;" type="checkbox" name="filtGeneric" id="generictrap6" value="6">
					          <label class="error-status" for="generictrap6">扩展消息</label>
				    		</td>
				    		<span class="pageTip" style="width:200px"></span>
			    		</tr>
			    		
			    		<tr style="height:40px">
				    		<td class="td_left">
								消息内容
				    		</td>
				    		<td class="td_right">
				    			<textarea style="width: 600px;height: 30px;" id="filtMsg" name="filtMsg"></textarea>
    					        <span class="pageTip" style="width:200px"></span>
				    		</td>
			    		</tr>
			  		</table>
			  		<div style="margin-left:150px; margin-top:5px;">
				    	<input type="submit" id="button" name="button" value="保存" class="btn-4">
				    	<input type="button" value="重置" class="btn-4" onclick="pageReset();">
				    	<input type="button" value="返回" onclick="back();" class="btn-4">
		    		</div>
		    		<input id="id" name="id" type="hidden">
				</form>
			</div>
</body>
</html>